<template>
  <div class="container">
    <!-- 标题 -->
    <van-nav-bar title="确认订单"
                 left-arrow
                 @click-left="onClickLeft"
    />
    <div class="address">{{this.$store.state.mineAddress.address}}</div>
    <!-- 收货人信息 -->
    <div class="consignee">
      <span>收货人：{{this.$store.state.mineAddress.name}}</span>
      <span>{{this.$store.state.mineAddress.tel}}</span>
    </div>
    <!-- 我的自提店地址 -->
    <MyAddress></MyAddress>
    <!-- 单个已选中的商品组件 -->
    <SingleChooseOrder v-for="(item) in this.$store.state.whichCheckd"
                       :key="item.goodsId"
                       v-show="item.checked"
                       :item="item"></SingleChooseOrder>
    <!-- 安全提示 -->
    <SafeTip></SafeTip>
    <!-- 提交订单 -->
    <SubmitOrder></SubmitOrder>
    <!-- 底部弹出层 -->
    <van-popup class="pop"
               v-model="$store.state.show"
               round
               position="bottom"
               :style="{ height: '35%' }">
      <p class="orderTip">下单提醒</p>
      <p class="tipText">请仔细确认地址以及个人信息</p>
      <div class="orderAddress">
        <p>配送地址：{{this.$store.state.mineAddress.address}}</p>
        <p>{{this.$store.state.mineAddress.address}} - 附近菜鸟驿站</p>
      </div>
      <div class="yesOrNo">
        <wd-button type="warning"
                   @click="$store.commit('hidePopup')">取消订单</wd-button>
        <wd-button type="error"
                   @click="toOnlinePay">确认订单</wd-button>
      </div>
    </van-popup>
  </div>
</template>

<script>
import SingleChooseOrder from './SingleChooseOrder'
import MyAddress from './MyAddress'
import SubmitOrder from './SubmitOrder'
import SafeTip from './SafeTip'

export default {
  name: 'MakeSure',
  components: {
    SingleChooseOrder,
    MyAddress,
    SubmitOrder,
    SafeTip,
  },
  methods: {
    onClickLeft() {
      this.$router.back()
    },
    toOnlinePay() {
      this.$router.push({ path: "/onlinePay" })
    }
  },
  created() {
    this.$store.state.whichCheckd = JSON.parse(localStorage.getItem('lastShopCarList')).whichCheckd
    this.$store.state.checkedAllPrice = JSON.parse(localStorage.getItem('allPrice')).allPrice
  }
}
</script>

<style lang='less' scoped>
@themeColor: #ec0d0d;
.container {
  height: 100%;
  min-height: calc(100vh - 110px);
  padding-bottom: 110px;
  background-color: #f0f0f0;
  box-sizing: border-box;
}
.address {
  height: 32px;
  color: #fff;
  text-align: center;
  background-color: @themeColor;
  font-size: 14px;
}
.consignee {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 38px;
  padding: 0 10px;
  font-size: 14px;
  border-bottom: 1px solid #f0f0f0;
  background-color: white;
}
.van-nav-bar__title {
  font-weight: 600;
}
.van-hairline--bottom::after {
  border: none;
}
/deep/.van-nav-bar__content {
  height: 45px;
}
.pop {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}
.orderTip {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 50%;
  height: 40px;
  background-color: #ec0d0d;
  color: white;
  border-bottom-right-radius: 15px;
  border-bottom-left-radius: 15px;
}
.tipText {
  color: rgba(236, 13, 13, 100);
  text-align: center;
}
.orderAddress {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 90%;
  height: 40%;
  padding: 15px;
  background-color: rgba(187, 187, 187, 28);
  border-radius: 10px;
  p:first-child {
    color: black;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  p:last-child {
    color: #ececec;
    text-align: center;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}
.yesOrNo {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 10px 10px 15px;
  box-sizing: border-box;
}
</style>